EnsureInitialized(T) Method (T, Boolean, Object, Func(T))

Task Parallel System.Threading

Initializes a target reference or value type with a specified function if it has not already been initialized.

Namespace:  System.Threading
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function EnsureInitialized(Of T) ( _
	ByRef target As T, _
	ByRef initialized As Boolean, _
	ByRef syncLock As Object, _
	valueFactory As Func(Of T) _
) As T
C#
public static T EnsureInitialized<T>(
	ref T target,
	ref bool initialized,
	ref Object syncLock,
	Func<T> valueFactory
)

Parameters

target
Type: T %
A reference or value of type T to initialize if it has not already been initialized.
initialized
Type: System..::.Boolean %
A reference to a boolean that determines whether the target has already been initialized.
syncLock
Type: System..::.Object %
A reference to an object used as the mutually exclusive lock for initializing target.
valueFactory
Type: System..::.Func<(Of <(T>)>)
The Func<(Of <(T>)>) invoked to initialize the reference or value.

Type Parameters

T
The type of the reference to be initialized.

Return Value

The initialized value of type T.

See Also